<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>CSS布局-flex (弹性盒子)</title>
    <style>
      h3 {
        width: 500px;
        margin: 20px auto;
      }
      .container {
        width: 500px;
        height: 200px;
        margin: 20px auto;
        padding: 10px;
        border: 1px solid black;
        display: flex;
      }
      .item {
        width: 100px;
        height: 100px;
        border: 1px solid red;
        margin: 10px;
      }
      .auto-width {
        width: auto;
        flex: auto;
      }
    </style>
  </head>
  <body>
    <h3>主轴 justify-content: start(缺省值); 侧轴 align-items: start(缺省值)</h3>
    <div class="container" style="justify-content: start; align-items: start">
      <div class="item">item1</div>
      <div class="item">item2</div>
      <div class="item">item3</div>
    </div>
    <h3>主轴 justify-content: center; 侧轴 align-items: center</h3>
    <div class="container" style="justify-content: center; align-items: center">
      <div class="item">item1</div>
      <div class="item">item2</div>
      <div class="item">item3</div>
    </div>
    <h3>主轴 justify-content: end; 侧轴 align-items: end</h3>
    <div class="container" style="justify-content: end; align-items: end">
      <div class="item">item1</div>
      <div class="item">item2</div>
      <div class="item">item3</div>
    </div>
    <h3>主轴 justify-content: space-around; 侧轴 align-items: baseline</h3>
    <div class="container" style="justify-content: space-around; align-items: baseline">
      <div class="item" style="padding-top: 20px">item1</div>
      <div class="item">item2</div>
      <div class="item">item3</div>
    </div>
    <h3>主轴 justify-content: space-between; 侧轴 align-items: stretch</h3>
    <div class="container" style="justify-content: space-between; align-items: stretch">
      <div class="item" style="height: auto">item1</div>
      <div class="item" style="height: auto">item2</div>
      <div class="item" style="height: auto">item3</div>
    </div>
    <h3>项目属性：flex:auto; width:auto, 项目主轴平分容器</h3>
    <div class="container">
      <div class="item auto-width">item1</div>
      <div class="item auto-width">item2</div>
      <div class="item auto-width">item3</div>
      <div class="item auto-width">item4</div>
      <div class="item auto-width">item5</div>
    </div>
  </body>
</html>
